<template>
	<view class="page">
		<view class="my_padding">
			<view class="feed_back">
				<textarea v-model="text" placeholder="请简单描述您的问题"></textarea>
			</view>
		</view>
		
		<view class="submit_order" @click="submitOrder">提交</view>
		
		<uni-popup ref="popupDialog" type="dialog">
			<uni-popup-dialog type="ok" :content="message" :show-cancel-button="false"
				@confirm="dialogConfirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import tabBar from '@/components/tabBar/tabBar.vue'
	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	export default {
		components: {
			tabBar,
			uniPopupDialog
		},
		data() {
			return {
				user_bg: '',
				avatar: '/static/icon_avatar.png',
				text: '',
				currentPage: '/pages/user/person',
				ifOnShow: false,
				unit: '',
				message: "感谢您的建议",
				showPopu: false
			};
		},
		onHide() {
			this.ifOnShow = true
		},
		onShow() {
			if (this.ifOnShow) {
				this.getData();
			}
			let pages = getCurrentPages();
			let currPage = pages[pages.length-1];
			if (currPage.$vm.bank_id){
				this.bank_id = currPage.$vm.bank_id;
				// this.loadData();
			}
		},
		onLoad: function(option) {
			// this.getData();
		},
		methods: {
			//user数据
			getData: function() {
				//获取基础参数
				// uni.showLoading({
				// 	title: "数据加载中",
				// 	mask: true
				// })
				var info = uni.getStorageSync("userinfo");
				if (info.token) {
					let timestamp = this.helper.now();
					let sign = this.helper.setSign(['username=' + info.username, 'token=' + info.token, 'timestamp=' +
						timestamp
					]);
					this.helper.req({
						api: "getUserInfo",
						timestamp: timestamp,
						data: {
							username: info.username,
							token: info.token
						},
						header: {
							sign: sign
						},
						method: 'GET',
					}).then(res => {
						// console.log('userInfo参数:', this.userinfo)
						
					})
				} else {
					// uni.hideLoading();
				}
			},
			navToUrl: function(url) {
				return uni.navigateTo({
					url: url
				});
			},
			imageError: function(e) {
				this.avatar = '/static/icon_avatar.png';
			},
			submitOrder: function(){
				if(this.text == ''){
					uni.showToast({
						title:"留言内容不能为空",
						icon:"none"
					})
					return;
				}
					var info = uni.getStorageSync("userinfo");
					let timestamp = this.helper.now();
					let sign = this.helper.setSign(['timestamp='+timestamp,'feedback='+this.text,'token='+info.token]);
					this.helper.req({
						api:"doFeedback",
						timestamp:timestamp,
						data:{
							token:info.token,
							feedback: this.text // 将文本框的内容作为参数传递
							},
						header:{sign:sign},
						method:'POST',
					}).then(res=>{
						
						uni.showModal({
							title: "提示",
							content: res.data.message,
							showCancel:false,
							confirmText: "确定",
							success:function(res){
								uni.redirectTo({
									url: '/pages/msg/index'
								})
							}
						})
					})
						
				//this.toggleMessage()
			},
			toggleMessage() {
				this.$refs.popupDialog.open()
			},
			dialogConfirm(done){
				done()
				// uni.redirectTo({
				// 	url: '/pages/user/person'
				// })
				uni.navigateBack()
			}
		},
	};
</script>

<style lang="scss">
	page {
background-color: #0D1A44;
	}
	
	.my_padding {

	}
	.feed_back textarea{
		width: 96vw;
		height: 50vw;
		margin: 2vw;
		background: #FFF;
		padding: 3vw;
		line-height: 24px;
	}
	
	.submit_order{
		width: 96%;
		padding: 12px;
		background: linear-gradient( 180deg, #50A7FF 0%, #3267FF 100%);
		color: #fff;
		font-size: 18px;
		text-align: center;
		border-radius: 6px;
		position: fixed;
		bottom: 10px;
		left: 2%;
	}

</style>
<!-- index -->
<style lang="scss" scoped>
	.tab-bar-footer {
		background-color: #fff;
		border-radius: 3.2vw;
		// margin: 3.33333vw auto 0;
		    margin-bottom: 60px;
			padding: 16px 0;
		width: 94vw;
		box-shadow: 0 0 25px rgba(0, 0, 0, 0.2);
	}

	.tab-bar {
		padding: 30px 0;
		background-color: #fff;
		border-radius: 3.2vw;
		// margin: 3.33333vw auto 0;
		width: 94vw;
		box-shadow: 0 0 25px rgba(0, 0, 0, 0.2);

	}
</style>
<!-- uni-grid -->
<style lang="scss" scoped>
	.image {
		width: 25px;
		height: 25px;
	}

	.text {
		margin-top: 10upx;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		// display: block;
		/* #endif */
	}

	.swiper {
		height: 420px;
	}

	/* #ifdef H5 */
	@media screen and (min-width: 768px) and (max-width: 1425px) {
		.swiper {
			height: 630px;
		}
	}

	@media screen and (min-width: 1425px) {
		.swiper {
			height: 830px;
		}
	}

	/* #endif */
</style>